package NO3_LinkedList;

/**
 * 2025-06-26
 * 链表节点类
 */
public class ListNode {
    int val;
    ListNode next;

    ListNode() {
    }

    ListNode(int val) {
        this.val = val;
    }

    ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }

    /**
     * 打印链表方法
     */
    public static void printList(ListNode head) {
        ListNode curr = head;
        while (curr != null) {
            System.out.print(curr.val + " -> ");
            curr = curr.next;
        }
        System.out.println("null");
    }

    /**
     * 打印单个节点
     */
    public static void printNode(ListNode node) {
        System.out.println(node.val);
    }
}
